using System;
using System.Linq.Expressions;
using ExtendedMvc.Elements;

namespace ExtendedMvc {
	public static class FormValidationExtensions {

		public static ValidationMessage<T> ValidationMessageFor<T>(this ModelViewForm<T> form, string targetId, string message = null) where T : class {
			return new ValidationMessage<T>(form.Helper, targetId).DefaultMessage(message);
		}

		public static ValidationMessage<T> ValidationMessageFor<T>(this ModelViewForm<T> form, Expression<Func<T, object>> expression, string message = null) where T : class {
			return new ValidationMessage<T>(form.Helper, expression.GetNameFor(form.Helper.ViewDataContainer)).DefaultMessage(message);
		}

		public static ValidationSummary<T> ValidationSummary<T>(this ModelViewForm<T> form, string message = null) where T : class {
			return new ValidationSummary<T>(form.Helper).DefaultMessage(message);
		}
	}
}
